package com.shuai.jit.controller;

import com.shuai.jit.entity.R;
import com.shuai.jit.entity.user.User;
import com.shuai.jit.service.impl.LoginServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/user")
public class RegisterController {



    @Autowired
    LoginServiceImpl loginService;

    @RequestMapping("/register")
    public R register(@RequestBody User user){

        Integer result = loginService.register(user);
        if(result>=1){
            return R.ok().data("register","成功");
        }else if(result==-1){
            return R.error().data("register","手机号或者用户名已经有了");
        }else if(result==-2){
            return R.error().data("register","对不起验证码错误");
        }
        else {
            return R.error().data("register","注册失败");
        }
    }
}
